home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 004-kdeapps.lzm / usr / bin / krfb_httpd < prev    next >
Encoding:
Text File  |  2007-05-14  |  1.6 KB  |  76 lines

  1. #! /usr/bin/env bash
  2.  
  3. if [ "$1" = "--kinetd" ]; then
  4.     # redirect stdin and stdout to the inetd socket.
  5.     exec <&$2 >&$2
  6. fi
  7.  
  8. read request url httptype || exit 0
  9. url="${url/
  10. /}"
  11. httptype="${httptype/
  12. /}"
  13.  
  14. if [ "x$httptype" != "x" ]; then
  15.     line="x"
  16.     while [ -n "$line" ]; do
  17.         read line || exit 0
  18.         line="${line/
  19. /}"
  20.     done
  21. fi
  22. # echo "url = $url, request = $request" >> /tmp/httpd.log
  23. case "$url" in
  24. /)
  25.     # We need the size of the display for the current applet.
  26.     size=`xdpyinfo -display :0| grep dimensions:|head -n 1|sed -e "s/.*dimensions: *//" -e "s/ pixels.*//"`
  27.     width=`echo $size|sed -e "s/x.*//"`
  28.     height=`echo $size|sed -e "s/.*x//"`
  29.     # The VNC menubar is 20 pixels high ...
  30.     height=$((height+20))
  31.  
  32.     port=`dcop kded kinetd port krfb`
  33.     if [ "$port" == "-1" ]; then
  34.         port=5900
  35.     fi
  36.  
  37.     ctype="text/html"
  38.     content="
  39. <HTML><HEAD><TITLE>$LOGNAME's desktop</TITLE></HEAD>
  40. <BODY>
  41. <APPLET CODE=VncViewer.class ARCHIVE=VncViewer.jar WIDTH=$width HEIGHT=$height>
  42.     <param name=PORT value=$port>
  43. </APPLET>
  44. </BODY></HTML>"
  45.     ;;
  46. *.jar|*.class)
  47.     # Use basename to make sure we have just a filename, not ../../...
  48.     url="`basename "$url"`"
  49.     ctype="application/octet-stream"
  50.     cfile="/usr/share/vnc/classes/$url"
  51.     content="FILE"
  52.     ;;
  53. esac
  54.  
  55. if [ "x$httptype" != "x" ]; then
  56.     echo "HTTP/1.0 200 OK"
  57.     echo "Content-Type: $ctype"
  58.     if [ "$content" == "FILE" ]; then
  59.         clen=`wc -c "$cfile"`
  60.     else
  61.         clen=`echo "$content"|wc -c`
  62.     fi
  63.     echo "Content-Length: $clen"
  64.     echo "Connection: close"
  65.     echo
  66. fi
  67.  
  68. if [ "$request" == "GET" ]; then
  69.     if [ "$content" == "FILE" ]; then
  70.         cat "$cfile"
  71.     else
  72.         echo "$content"
  73.     fi
  74. fi
  75. exit 0
  76.